Remove lots of no longer necessary + Send annotations
authorAlex Crichton <alex@alexcrichton.com>
Tue, 9 Dec 2014 18:50:06 +0000 (10:50 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 10 Dec 2014 03:57:06 +0000 (19:57 -0800)
src/cargo/util/errors.rs
src/cargo/util/result.rs

index fa215d4bbfa1810568e82158ea303d4a8a4bde8b..935a8ef4b6c5619ec79913548af5e518376078cb 100644 (file)
@@ -21,7 +21,7 @@ pub trait CargoError: Send {
         ConcreteCargoError {
             description: self.description(),
             detail: self.detail(),
-            cause: self.cause().map(|c| box c.concrete() as Box<CargoError + Send>),
+            cause: self.cause().map(|c| box c.concrete() as Box<CargoError>),
             is_human: self.is_human()
         }
     }
@@ -31,9 +31,9 @@ pub trait FromError<E> {
     fn from_error(error: E) -> Self;
 }
 
-impl<E: CargoError + Send> FromError<E> for Box<CargoError + Send> {
-    fn from_error(error: E) -> Box<CargoError + Send> {
-        box error as Box<CargoError + Send>
+impl<E: CargoError> FromError<E> for Box<CargoError> {
+    fn from_error(error: E) -> Box<CargoError> {
+        box error as Box<CargoError>
     }
 }
 
@@ -47,14 +47,14 @@ macro_rules! from_error (
     }
 )
 
-impl Show for Box<CargoError + Send> {
+impl Show for Box<CargoError> {
     fn fmt(&self, f: &mut Formatter) -> fmt::Result {
         try!(write!(f, "{}", self.description()));
         Ok(())
     }
 }
 
-impl CargoError for Box<CargoError + Send> {
+impl CargoError for Box<CargoError> {
     fn description(&self) -> String { (**self).description() }
     fn detail(&self) -> Option<String> { (**self).detail() }
     fn cause(&self) -> Option<&CargoError> { (**self).cause() }
@@ -67,30 +67,30 @@ impl CargoError for semver::ReqParseError {
     }
 }
 
-pub type CargoResult<T> = Result<T, Box<CargoError + Send>>;
+pub type CargoResult<T> = Result<T, Box<CargoError>>;
 
 pub trait BoxError<T> {
     fn box_error(self) -> CargoResult<T>;
 }
 
 pub trait ChainError<T> {
-    fn chain_error<E: CargoError + Send>(self, callback: || -> E) -> CargoResult<T> ;
+    fn chain_error<E: CargoError>(self, callback: || -> E) -> CargoResult<T> ;
 }
 
 impl<'a, T> ChainError<T> for ||:'a -> CargoResult<T> {
-    fn chain_error<E: CargoError + Send>(self, callback: || -> E) -> CargoResult<T> {
+    fn chain_error<E: CargoError>(self, callback: || -> E) -> CargoResult<T> {
         self().map_err(|err| callback().concrete().with_cause(err))
     }
 }
 
-impl<T, E: CargoError + Send> BoxError<T> for Result<T, E> {
+impl<T, E: CargoError> BoxError<T> for Result<T, E> {
     fn box_error(self) -> CargoResult<T> {
-        self.map_err(|err| box err as Box<CargoError + Send>)
+        self.map_err(|err| box err as Box<CargoError>)
     }
 }
 
-impl<T, E: CargoError + Send> ChainError<T> for Result<T, E> {
-    fn chain_error<E: CargoError + Send>(self, callback: || -> E) -> CargoResult<T>  {
+impl<T, E: CargoError> ChainError<T> for Result<T, E> {
+    fn chain_error<E: CargoError>(self, callback: || -> E) -> CargoResult<T>  {
         self.map_err(|err| callback().concrete().with_cause(err))
     }
 }
@@ -132,7 +132,7 @@ pub struct ProcessError {
     pub exit: Option<ProcessExit>,
     pub output: Option<ProcessOutput>,
     pub detail: Option<String>,
-    pub cause: Option<Box<CargoError + Send>>
+    pub cause: Option<Box<CargoError>>
 }
 
 from_error!(ProcessError)
@@ -192,20 +192,19 @@ impl CargoError for ProcessError {
 pub struct ConcreteCargoError {
     description: String,
     detail: Option<String>,
-    cause: Option<Box<CargoError + Send>>,
+    cause: Option<Box<CargoError>>,
     is_human: bool
 }
 
 impl ConcreteCargoError {
-    pub fn with_cause<E: CargoError + Send>(mut self,
-                                            err: E) -> Box<CargoError + Send> {
-        self.cause = Some(box err as Box<CargoError + Send>);
-        box self as Box<CargoError + Send>
+    pub fn with_cause<E: CargoError>(mut self, err: E) -> Box<CargoError> {
+        self.cause = Some(box err as Box<CargoError>);
+        box self as Box<CargoError>
     }
 
-    pub fn mark_human(mut self) -> Box<CargoError + Send> {
+    pub fn mark_human(mut self) -> Box<CargoError> {
         self.is_human = true;
-        box self as Box<CargoError + Send>
+        box self as Box<CargoError>
     }
 }
 
@@ -237,7 +236,7 @@ pub type CliResult<T> = Result<T, CliError>;
 
 #[deriving(Show)]
 pub struct CliError {
-    pub error: Box<CargoError + Send>,
+    pub error: Box<CargoError>,
     pub unknown: bool,
     pub exit_code: uint
 }
@@ -291,11 +290,11 @@ impl CliError {
     }
 
     pub fn from_error<E: CargoError + 'static>(error: E, code: uint) -> CliError {
-        let error = box error as Box<CargoError + Send>;
+        let error = box error as Box<CargoError>;
         CliError::from_boxed(error, code)
     }
 
-    pub fn from_boxed(error: Box<CargoError + Send>, code: uint) -> CliError {
+    pub fn from_boxed(error: Box<CargoError>, code: uint) -> CliError {
         let human = error.is_human();
         CliError { error: error, exit_code: code, unknown: !human }
     }
@@ -310,43 +309,43 @@ pub fn process_error<S: Str>(msg: S,
         exit: status.map(|o| o.clone()),
         output: output.map(|o| o.clone()),
         detail: None,
-        cause: cause.map(|c| box c as Box<CargoError + Send>)
+        cause: cause.map(|c| box c as Box<CargoError>)
     }
 }
 
 pub fn internal_error<S1: Str, S2: Str>(error: S1,
-                                        detail: S2) -> Box<CargoError + Send> {
+                                        detail: S2) -> Box<CargoError> {
     box ConcreteCargoError {
         description: error.as_slice().to_string(),
         detail: Some(detail.as_slice().to_string()),
         cause: None,
         is_human: false
-    } as Box<CargoError + Send>
+    } as Box<CargoError>
 }
 
-pub fn internal<S: Show>(error: S) -> Box<CargoError + Send> {
+pub fn internal<S: Show>(error: S) -> Box<CargoError> {
     box ConcreteCargoError {
         description: error.to_string(),
         detail: None,
         cause: None,
         is_human: false
-    } as Box<CargoError + Send>
+    } as Box<CargoError>
 }
 
-pub fn human<S: Show>(error: S) -> Box<CargoError + Send> {
+pub fn human<S: Show>(error: S) -> Box<CargoError> {
     box ConcreteCargoError {
         description: error.to_string(),
         detail: None,
         cause: None,
         is_human: true
-    } as Box<CargoError + Send>
+    } as Box<CargoError>
 }
 
-pub fn caused_human<S: Show, E: CargoError + Send>(error: S, cause: E) -> Box<CargoError + Send> {
+pub fn caused_human<S: Show, E: CargoError>(error: S, cause: E) -> Box<CargoError> {
     box ConcreteCargoError {
         description: error.to_string(),
         detail: None,
-        cause: Some(box cause as Box<CargoError + Send>),
+        cause: Some(box cause as Box<CargoError>),
         is_human: true
-    } as Box<CargoError + Send>
+    } as Box<CargoError>
 }
index e415f728866490b654c8747a3d4b366a896bb599..aeaa9645b10a1c6edcf8690d0c6db3b64a4aa5a2 100644 (file)
@@ -1,11 +1,11 @@
 use util::errors::{CargoResult, CargoError};
 
 pub trait Wrap {
-    fn wrap<E: CargoError + Send>(self, error: E) -> Self;
+    fn wrap<E: CargoError>(self, error: E) -> Self;
 }
 
-impl<T> Wrap for Result<T, Box<CargoError + Send>> {
-    fn wrap<E: CargoError + Send>(self, error: E) -> CargoResult<T> {
+impl<T> Wrap for Result<T, Box<CargoError>> {
+    fn wrap<E: CargoError>(self, error: E) -> CargoResult<T> {
         match self {
             Ok(x) => Ok(x),
             Err(e) => Err(error.concrete().with_cause(e))
@@ -14,14 +14,14 @@ impl<T> Wrap for Result<T, Box<CargoError + Send>> {
 }
 
 pub trait Require<T> {
-    fn require<E: CargoError + Send>(self, err: || -> E) -> CargoResult<T>;
+    fn require<E: CargoError>(self, err: || -> E) -> CargoResult<T>;
 }
 
 impl<T> Require<T> for Option<T> {
-    fn require<E: CargoError + Send>(self, err: || -> E) -> CargoResult<T> {
+    fn require<E: CargoError>(self, err: || -> E) -> CargoResult<T> {
         match self {
             Some(x) => Ok(x),
-            None => Err(box err().concrete() as Box<CargoError + Send>)
+            None => Err(box err().concrete() as Box<CargoError>)
         }
     }
 }